<%@ page  contentType="text/html; charset=UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="page" uri="http://www.forten.org/taglib/page"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>考勤短信</title>
<!-- CSS -->
<link type="text/css" rel="stylesheet" href="../styles/css/reset.css">
<link type="text/css" rel="stylesheet" href="../styles/css/index.css">
<link type="text/css" rel="stylesheet" href="../styles/css/button.css">
<script type="text/javascript" src="../scripts/html5.js"></script>
<!-- end -->
<!-- fancybox -->
<style type="text/css">
.textarea {
	color: gray;
}
.left-main{
  margin:0px;
  padding:0px;
  overflow:auto;
  overflow-x:hidden;
     }
</style>
<script>
	!window.jQuery
			&& document
					.write('<script src="../scripts/jquery-1.6.min.js"><\/script>');
</script>
<script type="text/javascript"
	src="../scripts/fancybox/jquery.fancybox-1.3.4.pack.js" charset="utf-8"></script>
<link media="screen" type="text/css" rel="stylesheet"
	href="../scripts/fancybox/jquery.fancybox-1.3.4.css">
<!-- end -->
<!-- 日期控件 -->
<script type="text/javascript" src="../scripts/Calendar/Js/calendar.js"></script>
<link type="text/css" rel="stylesheet"
	href="../scripts/Calendar/Css/calendar.css" />
<!-- end -->
</head>
<body>
	<script type="text/javascript">
	 function doSubmitLeaveReason(frmId,reasonsId){
		 var reason = $('#'+reasonsId).val();
		 if(reason == '请输入缺勤原因' || reason == '请输入请假原因'){
			 $('#'+reasonsId).val('');
		 }
		 
		 var formData = $('#'+frmId).serialize();
		 $.ajax({
				type:'post',
				data:formData,
				url:'../selectcourse/leaveQuick.jspx',
				success:function(data){
					
					// 出勤
					if(data == '0'){
						$('#state_td').html('出勤');
					} else 
					// 请假
					if(data == '1'){
						$('#state_td').html('请假');
					} else 
					// 缺勤
					if(data == '2'){
						$('#state_td').html('缺勤');
					}
						alert("操作成功！");
					//去除弹出窗效果
					$('#fancybox-close').click();
					$('#'+reasonsId).val(reason);
				}
			});
	  }
	
		function doQuery() {
			var start = $('#start');
			var end = $('#end');
			if(start.val() == '' && end.val() !=''){
				alert('请选择您要查询短信接收的起始时间！');
			}
			document.frm1.action = "showHandleCheckInShortMsg.jspx";
			document.frm1.submit();
		}
		$(document).ready(function() {
			<c:forEach items="${courseResultDto}" var="dto" varStatus="s">
			$("#leave${s.index }").fancybox({
				'titlePosition' : 'inside',
				'transitionIn' : 'none',
				'transitionOut' : 'none'
			});
			$("#state${s.index }").fancybox({
				'titlePosition' : 'inside',
				'transitionIn' : 'none',
				'transitionOut' : 'none'
			});
			$("#attend${s.index }").fancybox({
				'titlePosition' : 'inside',
				'transitionIn' : 'none',
				'transitionOut' : 'none'
			});
			$("#reasonInfo${s.index }").fancybox({
				'titlePosition' : 'inside',
				'transitionIn' : 'none',
				'transitionOut' : 'none'
			});
			
			   $("#leaveReason${s.index}").focus(function() {
			       if ($(this).val() == "请输入请假原因")
			           $(this).val("");
			       $(this).removeClass("textarea");
			   }).blur(function() {
			   if ($(this).val() == "") {
			           $(this).val("请输入请假原因"); $(this).addClass("textarea");
			       }
			   });
			   $("#absentReason${s.index}").focus(function() {
			       if ($(this).val() == "请输入缺勤原因")
			           $(this).val("");
			       $(this).removeClass("textarea");
			   }).blur(function() {
			   if ($(this).val() == "") {
			           $(this).val("请输入缺勤原因"); $(this).addClass("textarea");
			       }
			   });
			   
			   </c:forEach>
			   
		});
		
		function doDeleteShortMsg(msgId,trId){
			 if(confirm('您正在删除此条短信，继续吗？')){
				 $.ajax({
						type:'post',
						url:'../selectcourse/deleteShortMsg.jspx?id='+msgId,
						success:function(data){
							if(data =='删除成功'){
								$('#'+trId).remove();
							}
						}
					});
		 } else {
			 return false;
		 }
		}
	</script>
	<c:if test="${! empty message}">
		<script type="text/javascript" language="javascript">
		 window.onload =function(){
			 var message = "${message}";
			 alert(message);
		 }
		</script>
	</c:if>

	<header>
	<div class="headerWrap"></div>
	</header>

	<div class="content">

		<section>
		<div class="rc_fbt">
			<form:form id="frm1" name="frm1" modelAttribute="msgResultOfChekInQo"
				action="showHandleCheckInShortMsg.jspx">
				<span class="left"> 
				
					<span class="ml15 mr5 left">短信接收从</span>
					<form:input path="start" class="s_txt left mt13" 
					onclick="displayCalendar(this, 'yyyymmdd', this, false, '');"
										size="8" maxlength="8" readonly="true"/>
					<span class="ml15 mr5 left">至</span>
					<form:input path="end" class="s_txt left mt13" 
					onclick="displayCalendar(this, 'yyyymmdd', this, false, '');"
										size="8" maxlength="8" readonly="true"/>
					
				<%-- <span class="ml15 mr5 left">工作证号</span>
				<form:input path="cardNum" class="s_txt left mt13" /> --%>
				<span class="mlr15 left">干部姓名</span> 
				<form:input path="cadreName" class="s_txt ml5 left mt13" />
				<span class="mlr15 left">课程名</span>
				<form:input path="courseName" class="s_txt ml5 left mt13" />
				
				<a class="btn_search ml10 left mt10" href="#" onclick="doQuery();"></a>
				</span>
			</form:form>
		</div>
		
		<!-- 考勤短信信息 start -->
		<div class="rc_info mt20">
			<h3>
				<span class="r_title_ico"></span> 考勤短信信息
			</h3>
		</div>
		<div style="max-height: 250px;width: 978px;" class="left-main">
		<table class="rc_tab01" cellspacing="0" cellpadding="0">
			<tbody>
				<tr>
					<th style="text-align: center;width: 9%">
						工作证号
					</th>
					<th style="text-align: center;width: 9%">
						干部姓名
					</th>
					<th style="text-align: center;width: 9%">
						手机号码
					</th>
					<th style="text-align: center;width: 16%">
						接收时间
					</th>
					<th style="text-align: center;width: 52%">
						短信内容
					</th>
					<th style="text-align: center;width: 5%">
						操作
					</th>
				</tr>
				<c:forEach items="${resultDto}" var="result" varStatus="s">
				<tr id="tr${s.index }">
					<td style="text-align: center;">
						${result.cadreDto.cardNum }
					</td>
					<td style="text-align: center;">
						${result.cadreDto.name }
					</td>
					<td style="text-align: center;">
						${result.cadreDto.mobileNum }
					</td>
					<td style="text-align: center;">
					<fmt:formatDate value="${result.receiptTime }" pattern="yyyy年MM月dd日HH点mm分" />
					</td>
					<td style="text-align: center;">
						${result.content }
					</td>
					<td style="text-align: center;">
					<a href="#" onclick="doDeleteShortMsg('${result.id}','tr${s.index }');">
					删除
					</a>
					</td>
				</tr>
				</c:forEach>
			</tbody>
		</table>
		</div>
		<!-- 考勤短信信息 end -->
		
		<!-- 选课信息 start -->
		<div class="rc_info mt20">
			<h3>
				<span class="r_title_ico"></span> 选课信息
			</h3>
		</div>
		
		<div style="max-height: 300px;width: 978px;" class="left-main">
		<table class="rc_tab01" cellspacing="0" cellpadding="0">
			<tbody>
				<tr>
					<th style="text-align: center;width: 9%">工作证号</th>
					<th style="text-align: center;width: 9%">干部姓名</th>
					<th style="text-align: center;width: 25%">课程名</th>
					<th style="text-align: center;width: 16%">上课时间</th>
					<th style="text-align: center;width: 8%">上课状态</th>
					<th style="text-align: center;width: 8%">考勤短信</th>
					<th style="text-align: center;width: 25%">操作</th>
				</tr>
				<c:forEach items="${courseResultDto}" var="dto" varStatus="s">
					<tr>
						<td style="text-align: center;">${dto.cadreDto.cardNum}</td>
						<td style="text-align: center;">${dto.cadreDto.name}</td>
						<td style="text-align: center;">${dto.courseDto.name}</td>
						<td style="text-align: center;">
						<fmt:formatDate value="${dto.courseDto.teachTime }" pattern="yyyy年MM月dd日HH点mm分" />
						</td>
						<td style="text-align: center;" id="state_td">
						
						<c:if test="${dto.state =='0'}">
							出勤
						</c:if>
						
						<c:if test="${dto.state =='1'}">
							请假
						</c:if>
						
						<c:if test="${dto.state =='2'}">
							缺勤
						</c:if>
						
							<%-- <div style="display: none;">
								<div id="inline0${s.index }"
									style="width: 400px; height: 120px; overflow: auto; word-break: break-all;">
								<fieldset>${dto.stateExplanation }</fieldset>
								</div>
							</div> --%>
						</td>
						
						<td style="text-align: center;">
						A/B
						</td>
						<td class="rc_cr" style="text-align: center;"><a id="leave${s.index }"
							href="#inline2${s.index }" title="请假明细">请假</a> &nbsp;|&nbsp; <a
							id="state${s.index }" href="#inline3${s.index }" title="缺勤原因">缺勤</a>
							&nbsp;|&nbsp; <a id="attend${s.index }" href="#inline4${s.index }" title="修改为出勤状态">出勤</a>

							<div style="display: none;">
								<div id="inline2${s.index }"
									style="width: 400px; height: 120px; overflow: auto; word-break: break-all;">
									<form action="leaveQuick.jspx" method="post" id="frm2${s.index }">
										<input type="hidden" value="${dto.id}" name="selectedCourseId"
											id="selectedCourseId" />
										<textarea rows="4" cols="30" name="leaveReason"
											id="leaveReason${s.index }" class="textarea">请输入请假原因</textarea>
										<input type="hidden" value="1" id="state" name="state">
										<br> <input type="button" value="确定" class="button" onclick="doSubmitLeaveReason('frm2${s.index }','leaveReason${s.index }');"/>
									</form>
								</div>
							</div>

							<div style="display: none;">
								<div id="inline3${s.index }"
									style="width: 400px; height: 120px; overflow: auto; word-break: break-all;">
									<form action="leaveQuick.jspx" method="post" id="frm3${s.index }" >
										<input type="hidden" value="${dto.id}" name="selectedCourseId"
											id="selectedCourseId" />
										<textarea rows="4" cols="30" name="leaveReason"
											id="absentReason${s.index }" class="textarea">请输入缺勤原因</textarea>
										<input type="hidden" id="state" name="state" value="2" />
										<br> <input type="button" value="确定" class="button" onclick="doSubmitLeaveReason('frm3${s.index }','absentReason${s.index }')"/>
									</form>
								</div>
							</div>

							<div style="display: none;">
								<div id="inline4${s.index }"
									style="width: 400px; height: 120px; overflow: auto; word-break: break-all;">
									<form action="leaveQuick.jspx" method="post" id="frm4${s.index }">
										<input type="hidden" value="${dto.id}" name="selectedCourseId"
											id="selectedCourseId" />
										<input type="hidden" name="leaveReason" value="" />
										<textarea rows="4" cols="30" disabled="disabled">您正在修改此干部为出勤状态，如无特殊原因请不要执行此操作！</textarea>
										<input type="hidden" value="0" id="state" name="state">
										<br> <input type="button" value="确定" class="button" onclick="doSubmitLeaveReason('frm4${s.index }','')"/>
									</form>
								</div>
							</div>
							
						</td>
					</tr>
				</c:forEach>
			</tbody>
		</table>
		</div>
		<%-- <page:page hrefStr="showHandleCheckInShortMsg.jspx" name="page"></page:page> --%>

		</section>
	</div>

<%@include file="/common/foot.jsp"%>